<?php session_start(); 

	class testPayment extends PHPUnit_Framework_TestCase {

		public function testPaymentFunctionality() {
			$customerCost = 15.65;
			$this->assertEquals($customerCost, 15.65);
   
   			$tax = (.0825) * $customerCost;
			$this->assertEquals($tax, (.0825 * $customerCost));

   			$total = $tax + $customerCost;
			$this->assertEquals($total, ($tax + $customerCost));

   			$current_total = $total;
			$this->assertEquals($current_total, $total);
   
   			if(isset($_POST['addtip'])) {
				$tmp = "<td>\n";
				$this->assertStringEndsWith("<td>\n", $tmp);

				$tmp .= "<form method=\"post\">\n";
				$this->assertStringEndsWith("<td>\n" . "<form method=\"post\">\n", $tmp);

				$tmp .= "<button class=\"backButton\" name=\"small\">10%</button>\n";
				$this->assertStringEndsWith("<button class=\"backButton\" name=\"small\">10%</button>\n" . "<td>\n" . "<form method=\"post\">\n", $tmp);

				$tmp .= "<button class=\"backButton\" name=\"mid\">15%</button>\n";
				$this->assertStringEndsWith("<button class=\"backButton\" name=\"mid\">15%</button>\n" . "<button class=\"backButton\" name=\"small\">10%</button>\n" . "<td>\n" . "<form method=\"post\">\n", $tmp);

				$tmp .= "<button class=\"backButton\" name=\"large\">20%</button>\n";
				$this->assertStringEndsWith("<button class=\"backButton\" name=\"large\">20%</button>\n" . "<button class=\"backButton\" name=\"mid\">15%</button>\n" . "<button class=\"backButton\" name=\"small\">10%</button>\n" . "<td>\n" . "<form method=\"post\">\n", $tmp);

				$tmp .= "</form>\n";
				$this->assertStringEndsWith("</form>\n" . "<button class=\"backButton\" name=\"large\">20%</button>\n" . "<button class=\"backButton\" name=\"mid\">15%</button>\n" . "<button class=\"backButton\" name=\"small\">10%</button>\n" . "<td>\n" . "<form method=\"post\">\n", $tmp);

				$tmp .= "</td>\n";
				$this->assertStringEndsWith("</td>\n" . "</form>\n" . "<button class=\"backButton\" name=\"large\">20%</button>\n" . "<button class=\"backButton\" name=\"mid\">15%</button>\n" . "<button class=\"backButton\" name=\"small\">10%</button>\n" . "<td>\n" . "<form method=\"post\">\n", $tmp);
   			}
   			if(isset($_POST['small'])) {
				$tip_total = ($total * .10);
				$this->assertEquals($tip_total, ($total * .10));

				$current_total += $tip_total;
				$this->assertGreaterThanOrEqual($tip_total, $current_total);
   			}
   			elseif(isset($_POST['mid'])) {
				$tip_total = ($total * .15);
				$this->assertEquals($tip_total, ($total * .10));

				$current_total += $tip_total;
				$this->assertGreaterThanOrEqual($tip_total, $current_total);
   			}
   			if(isset($_POST['large'])) {
				$tip_total = ($total * .20);
				$this->assertEquals($tip_total, ($total * .20));

				$current_total += $tip_total;
				$this->assertGreaterThanOrEqual($tip_total, $current_total);
   			}
		}
	}
?>
